#ifndef PROPERTYBOX_H
#define PROPERTYBOX_H

#include <BMenu>
#include <BMenuBar>
#include <BLineEdit>
#include <BTableWidget>
#include <BHtmlWidget>
#include <BTreeWidget>
#include <BComboBox>
#include <BButton>
#include <BGroupBox>

using namespace BWE;

class PropertyBox : public BGroupBox
{
	BOBJECT(PropertyBox)
public:
	PropertyBox(BWidget* parent = 0);
	~PropertyBox();

	void attachHtmlWidget(BHtmlWidget* htmlWidget);

	virtual BSize sizeHint() const;

protected:
	void resetTreeWidget(BXmlNode* xmlNode);
	BTreeItem* createTreeItem(BXmlNode* xmlNode);
	void freshTreeItemIcon(BTreeItem* item);
	void updateEditable();
	void adjustEditButton();

protected:
	void slotHtmlWidgetReadOnly(BObject* object, const BValue& value);
	void slotHtmlItemSelected(BObject* object, const BValue& value);
	void slotHtmlItemChanged(BObject* object, const BValue& value);
	void slotHtmlItemTextChanged(BObject* object, const BValue& value);
	void slotNameEditFinished(BObject* object, const BValue& value);
	void slotNameBoardFramed(BWidget* widget, const BValue& value);
	void slotNameItemClicked(BObject* object, const BValue& value);
	void slotFormatEditFinished(BObject* object, const BValue& value);
	void slotAttribItemDoubleClicked(BObject* object, const BValue& value);
	void slotAttribItemSelected(BObject* object, const BValue& value);
	void slotAttribTableFreshed(BObject* object, const BValue& value);
	void slotAttribEditFinished(BObject* object, const BValue& value);
	void slotAttribEditFocused(BObject* object, const BValue& value);

	void slotInsertRowButtonClicked(BObject* object, const BValue& value);
	void slotRemoveRowButtonClicked(BObject* object, const BValue& value);
	void slotEditButtonClicked(BObject* object, const BValue& value);

	void slotTreeItemSelected(BObject* object, const BValue& value);
	void slotTreeItemRightClicked(BObject* object, const BValue& value);
	void slotTreeMenuTriggered(BObject* object, const BValue& value);

protected:
	virtual void styleEvent(const BEvent& event);

private:
	BComboBox*			_encodeComboBox;
	BLineEdit*			_titleLineEdit;
	BLineEdit*			_styleSheetEdit;
	BComboBox*			_nameComboBox;
	BLineEdit*			_formatEdit;
	BTableWidget*		_attribTable;
	BButton*			_insertRowButton;
	BButton*			_removeRowButton;
	BLineEdit*			_attribEdit;
	BButton*			_editButton;
	BTreeWidget*		_treeWidget;
	BMenu*				_treeMenu;

	BHolder<BHtmlWidget>	_htmlWidget;
	BHolder<BXmlNode>		_htmlNode;
};

#endif